package com.breeze.blockchain.controller.app.form.login;

import com.breeze.blockchain.common.enums.LoginTypeEnum;
import com.breeze.components.core.enums.EnumInterface;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotNull;

/**
 * 用户登陆注册表单
 *
 * @author breeze
 */
@Schema(description = "用户登陆注册表单")
public record UserLoginForm(
    @Schema(title = "手机号") String mobile,
    @Schema(title = "邮箱") String email,
    @Schema(title = "登陆类型") @NotNull(message = "登陆类型不能为空") @Min(1) @Max(3) Integer loginType,
    @Schema(title = "密码") String password,
    @Schema(title = "验证码") String code) {

  public LoginTypeEnum mapToLoginType() {
    return EnumInterface.fromCodeElse(LoginTypeEnum.class, loginType(), LoginTypeEnum.PASSWORD);
  }
}
